﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace knight_game
{
    class Program
    {
        static int[] playerPos = { 1, 2 }; //int[] Pos = new int[2] {1, 2};
        static string[] names = new string[2]; //name[0]存玩家A的姓名 name[10]存玩家B的姓名
        static int[] Map = new int[100];

        static void Main(string[] args)
        {
            ShowUI();//显示游戏名称

            Console.WriteLine("请输入玩家A的名字：");
            names[0] = Console.ReadLine();
            //判断用户输入的内容是否为空，如果为空，则让用户重新输入
            while (names[0] == "")
            {
                Console.WriteLine("玩家A的姓名不能为空，请重新输入：");
                names[0] = Console.ReadLine();
            }

            Console.WriteLine("请输入玩家B的名字：");
            names[1] = Console.ReadLine();
            //判断用户输入的内容是否为空，如果为空，则让用户重新输入
            while (names[1] == "" || names[1] == names[0])
            {
                if (names[1] == "")
                {
                    Console.WriteLine("玩家B的姓名不能为空，请重新输入：");
                }
                if (names[1] == names[1])
                {
                    Console.WriteLine("该姓名已被玩家A占用！请重新输入：");
                }
                names[1] = Console.ReadLine();
            }
            Console.Clear();

            ShowUI();

            Console.WriteLine("对战开始.....");
            Console.WriteLine("{0}用A来表示", names[0]);
            Console.WriteLine("{0}用B来表示", names[1]);
            Console.WriteLine("如果AB在同一位置，用<>来表示");
            Console.WriteLine("图例：幸运轮盘：◎  地雷：☆  暂停:▲  时空隧道：卐");
            Console.WriteLine();

            InitialMap(Map);

            //绘制图形
            for (int i = 0; i < 30; i++)
            {
                Console.Write(GetMapString(i));
            }

            Console.WriteLine();
            for (int i = 30; i < 35; i++)
            {
                for (int j = 0; j < 29; j++)
                    Console.Write("　");
                Console.WriteLine(GetMapString(i));
            }

            for (int i = 64; i >= 35; i--)
            {
                Console.Write(GetMapString(i));
            }

            Console.WriteLine();
            for (int i = 65; i < 70; i++)
            {
                Console.Write(GetMapString(i));
                for (int j = 0; j < 29; j++)
                    Console.Write("　");
                Console.WriteLine();
            }

            for (int i = 70; i < 100; i++)
            {
                Console.Write(GetMapString(i));
            }
            Console.WriteLine();

            Console.ResetColor();
            Console.WriteLine("开始游戏....");
        }


        /// <summary>
        /// 用于绘制飞行棋的名称
        /// </summary>
        static void ShowUI()
        {
            Console.WriteLine("******************************************");
            Console.WriteLine("*                                        *");
            Console.WriteLine("*            骑 士 飞 行 棋              *");
            Console.WriteLine("*                                        *");
            Console.WriteLine("******************************************");
			Console.WriteLine("****************测试增加******************");
			Console.WriteLine("****************测试增加2*****************");
        }

        /// <summary>
        /// 用于初始化地图存放编号
        /// </summary>
        /// <param name="map"></param>
        static void InitialMap(int[] map)
        {
            int[] luckyTurn = { 6, 23, 40, 55, 69, 83, 98 };
            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };
            int[] pause = { 9, 27, 60, 93 };
            int[] timeTunnel = { 20, 25, 45, 63, 72, 88 };

            for (int i = 0; i < luckyTurn.Length; i++)
                map[luckyTurn[i]] = 1;
            for (int i = 0; i < landMine.Length; i++)
                map[landMine[i]] = 2;
            for (int i = 0; i < pause.Length; i++)
                map[pause[i]] = 3;
            for (int i = 0; i < timeTunnel.Length; i++)
                map[timeTunnel[i]] = 4;
        }

        /// <summary>
        /// 用于显示Map内容
        /// </summary>
        /// <param name="sz"></param>
        static string GetMapString(int pos)
        {
            string str = "";
            if (playerPos[0] == pos && playerPos[1] == pos)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                str = "<>";
            }
            else if (playerPos[0] == pos)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                str = "Ａ";
            }
            else if (playerPos[1] == pos)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                str = "Ｂ";
            }
            else
                switch (Map[pos])
                {
                    case 0:
                        Console.ForegroundColor = ConsoleColor.White;
                        str = "□";
                        break;
                    case 1:
                        Console.ForegroundColor = ConsoleColor.Red;
                        str = "◎";
                        break;
                    case 2:
                        Console.ForegroundColor = ConsoleColor.Green;
                        str = "☆";
                        break;
                    case 3:
                        Console.ForegroundColor = ConsoleColor.Blue;
                        str = "▲";
                        break;
                    case 4:
                        Console.ForegroundColor = ConsoleColor.DarkBlue;
                        str = "卐";
                        break;
                }
            return str;
        }
    }
}
